package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VisitGuideCate;
import com.ruoyi.system.service.IVisitGuideCateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 就诊指南分类Controller
 * 
 * @author ruoyi
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/system/cate")
public class VisitGuideCateController extends BaseController
{
    @Autowired
    private IVisitGuideCateService visitGuideCateService;

    /**
     * 查询就诊指南分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:cate:list')")
    @GetMapping("/list")
    public TableDataInfo list(VisitGuideCate visitGuideCate)
    {
        startPage();
        List<VisitGuideCate> list = visitGuideCateService.selectVisitGuideCateList(visitGuideCate);
        return getDataTable(list);
    }

    /**
     * 导出就诊指南分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:cate:export')")
    @Log(title = "就诊指南分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VisitGuideCate visitGuideCate)
    {
        List<VisitGuideCate> list = visitGuideCateService.selectVisitGuideCateList(visitGuideCate);
        ExcelUtil<VisitGuideCate> util = new ExcelUtil<VisitGuideCate>(VisitGuideCate.class);
        util.exportExcel(response, list, "就诊指南分类数据");
    }

    /**
     * 获取就诊指南分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(visitGuideCateService.selectVisitGuideCateById(id));
    }

    /**
     * 新增就诊指南分类
     */
    @PreAuthorize("@ss.hasPermi('system:cate:add')")
    @Log(title = "就诊指南分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VisitGuideCate visitGuideCate)
    {
        return toAjax(visitGuideCateService.insertVisitGuideCate(visitGuideCate));
    }

    /**
     * 修改就诊指南分类
     */
    @PreAuthorize("@ss.hasPermi('system:cate:edit')")
    @Log(title = "就诊指南分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VisitGuideCate visitGuideCate)
    {
        return toAjax(visitGuideCateService.updateVisitGuideCate(visitGuideCate));
    }

    /**
     * 删除就诊指南分类
     */
    @PreAuthorize("@ss.hasPermi('system:cate:remove')")
    @Log(title = "就诊指南分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(visitGuideCateService.deleteVisitGuideCateByIds(ids));
    }
}
